<%@ page language="java" pageEncoding="utf-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>

<html:base />
<script type="text/javascript">
      var xmlhttp =null;
      var checkresult=1;
      if(window.ActiveXObject){
           xmlhttp=new ActiveXObject("Microsoft.XMLHttp");
      }else if(window.XMLHttpRequest){
           xmlhttp=new XMLHttpRequest();  
      } 
      var checkresult=null;
      var username =null;
      function init(user){
     //window.alert("initing...");
      username=user;
      Checkmail();
      window.setInterval('Checkmail()',15*1000);//每隔5秒自动调用Checkmail()
      }

      function Checkmail(){
      //window.alert("will get new message");
      xmlhttp.open("POST", "../servlet/GetMessage", false);
      xmlhttp.onreadystatechange = updatePage;
      xmlhttp.send();
      }
      function updatePage() {
          var message=document.getElementById("message");
          if (xmlhttp.readyState < 4) {
               message.innerHTML="loading...";
          }else if (xmlhttp.readyState == 4) {
                var response = xmlhttp.responseText;
                //alert(response);
                if(response==-1)return;
                if(response=="3"){//没有新信息
                      message.innerHTML=""
                      checkresult=1;
                }else if(response=="2"){   //有信息 
                      var html="<a href='../getMyMessage.do'><img src='../img/message.bmp' border='0' alt='未读信息'></a>";
                      checkresult=0;
                      message.innerHTML=html;
                }else if(response=="1"){
                      var html="<a href='../getMyMessage.do'><img src='../img/message_new.bmp' border='0' alt='新信息'></a>"; 
                     /* html=html+ "<EMBED src='../music/message.mp3' HIDDEN='true' autostart='true' loop='false'></EMBED>"; */
                      message.innerHTML=html;
                 }     
       }
   }
      
</script>
<style>
   ._padding{
     padding-left:20px;
     padding-right:20px;
     }
      
</style>


<table width="100%" class="_padding">
	<tr><td><h1>${user.name} 欢迎光临一品粥吧<br />www.yipinzhouba.com<br />我家店就在你家楼下</h1></td>
		<td width="800px" align="right" valign="top">
			<span id="message">消息<logic:present name="newmessagecount">(<bean:write name="newmessagecount" />)</logic:present></span>
			<script type="text/javascript">init("");</script>
			<a onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.yipinzhouba.com');"
				href="http://www.yipinzhouba.com">设为首页</a>|
			<a href="javascript:window.external.AddFavorite('http://www.yipinzhouba.com','一品粥吧')">加入收藏</a>|
			<html:link page="/forwardToReg.do">注册</html:link>|
			<html:link page="/forwardToLog.do">登陆</html:link>|
			<html:link page="/out.do">退出</html:link>|
			<logic:present name="user">
			<logic:equal value="3" name="user" property="role"><html:link page ="/saler/home.action">我的店铺</html:link>|</logic:equal>
			<logic:equal value="2" name="user" property="role"><html:link page="/forwardToIndex.do">我要买</html:link>|</logic:equal> 
			</logic:present>
			<html:link page="/getCart.do">购物车<logic:present name="orderitemsize">(<bean:write name="orderitemsize" />)</logic:present></html:link>|
			<html:link page="/getMyScore.do">积分记录</html:link>|我的资料|
			<html:link page="/getOrders.do">购买记录</html:link>
			<br />
			<h1>粥！温暖您的胃，服务温暖您的心</h1>
			<h1>粥！能吃好，也能吃饱<br><html:link page="/test/test.action">测试</html:link></h1>
			 <logic:present name="latest_order"> 
			 您在${latest_order.orderTime}下的订单
			   <logic:equal name="latest_order" property="state" value="0"><font color="red">还未处理，如果5分钟还没处理，可能需要联系15900659396</font></logic:equal>
               <logic:equal name="latest_order" property="state" value="1"><font color="blue">已处理，请放心</font></logic:equal>
               <logic:equal name="latest_order" property="state" value="2"><font color="green">已发货，即可就到</font></logic:equal>
			  </logic:present>
		</td>
	</tr>
</table>
